// pages/homepageNew/homepageNew.js
let app = getApp();
var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
var qqmapsdk;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    film:[],
    actor:[],
    news:[],
    address:[],
    isAuth: false,
    hotFilm:1,
    comeingsoon:0,
    selectId:"",
    videos:0,
    src: ['http://183.240.141.12/om.tc.qq.com/AwF56d32rSXLfF91rZy57Zb-oXQTSaZN2Rm-_ASpf7nw/uwMROfz2r57EIaQXGdGnCmdePkbGk05ufqw7HrTuARKydJvJ/svp_50001/szg_6924_50001_0b6biiadgaaaoaabijvaifpvcqwdgnbaam2a.f622.mp4?vkey=18C1B697CA0A7860E48595544C2C58CD231EB9B587C3374CC43883B365B34C1D6F31294B1B11EFC2A611D3A3BD2BBB75F62A0BD8E171305BF7928CE58296927BDAD25F32000F906657CEA0F4B337F176BBFA810880C22A1798CD034DBA5DCC379CE2FE6A44FF80BAEBF0095C5FE5C009','http://117.169.70.151/om.tc.qq.com/A9RGflxOpBXpn8DNV8wedvQ6ec7NtwxqjpNuhlURPV8g/uwMROfz2r57EIaQXGdGn02dePkY-jD0Ikg-uW5DXlqiONNNR/svp_50001/szg_2169_50001_0b6baeaecaaadyakmsmxb5pvcaodieaqaqka.f622.mp4?vkey=79F3414F7B433CD4129C5D5205D05FA036AE0A6422F23D199DBE6359B0854EFCFC3A681CA1D70896500F015EFFAAFEA9435DE6E469FDF168DEDA93A3C93546FD38BAACF01F9BC1B659DC49882661D775013F6397F137B103699BC731748C1C9FB90326269AE4C44FDF80297275D5CC20','http://117.169.112.214/om.tc.qq.com/A9M77GGdJOLZV11Sq_A5oO-CMtX5rbLrgHDXe9ciXgVM/uwMROfz2r57EIaQXGdGnCmdePkbGk05ufqw7HrTuARKydJvJ/svp_50001/szg_9174_50001_0b6bj4abgaaaoqakhy3vl5pvct6dcnhqae2a.f622.mp4?vkey=CFBCCCE7AEEAC5972F2BBD73272326E9471E208A58BCEC41DBF8865F629DF51553C260D8805C78149460613B070E70E5906E984F2861823B3B699B86E86FA02F80E8EA0F8050CF25A5BC4848B30AEE59E25EF0E3411F5028D69D92F206DA5005FE63E1CE6F99BD4D0C9BAEA1410D855D','http://183.232.63.150/om.tc.qq.com/A1MK96SiAkKNwcYDtlDlSJTcfSsRLlCkvaItMkrWbAJs/uwMROfz2r5zEIaQXGdGnCWdfhzn1duevvfhxzj7Rzmf04skR/q3165mxvzui.m701.mp4?vkey=565D75B46D77ABFFDA79F34FAE4D648B98949D259D511B4E1C2599FD86640BB5414B90643396421DB44FB0FCD445855A55B6393E26F4C67C68C24950C1381E6018DCB86C854D262C32E8C49534B480763C7FB5E7199E0FB15C879A921C540A5C3CF83E6F481F7814973686ABA416629E'],
    videoss:0,
    srcc:['http://117.169.112.218/om.tc.qq.com/AE1Swl9ltpUAJGjVJ5NtFWJz6emstbW3jaWhKXW_39o4/uwMROfz2r57EIaQXGdGnCmdeB3fgknVQ2ka7lVOx5fcA-YGW/svp_50001/szg_76651335_50001_b3b5cd3155ba4b159e14a2c2a0d39c98.f622.mp4?vkey=59BCCA0590D83497C7493773E76DB4678F091C2976B9EA6A13BE8F96DE52C5BC770F4397B4DACDDDA26C5CF13CAD915A27557E723B3AE2A395DF842665F345194EB18731F336FB9001C48BADD279246871CD77AE374BF637CE121CA866D35ED0EFAA2BA8BCD8D88E38DB4813BD101A73','http://183.252.54.23/vlive.qqvideo.tc.qq.com/AwqrAmby7c4-3iMDEzvs2DHoEdNV-YbNR7dQm6Mv_xD4/uwMROfz2r5zEIaQXGdGnCmdfiMXii0lhkOckIibit_3P4WM8/i0034r7ehtz.m1.mp4?vkey=633DEEAEFF488080F55D0C90033CB0B0EBC60875414541904237A41605C6DF15FCC9EA3CFA6D69760001E3150CADE635E4F11228806CB36FB59044361D77EF39B1A037F36CB53AF3EC3634453427BAC7C79159DBBFA6CC47CDCAC41395724D8B90F12E32BF78AA1577DBDB42F4DB11FC','http://117.169.70.146/om.tc.qq.com/ATotvm5TNFVetMAZ6TCazaMFP-QR9x39grhN9vIouUkw/uwMROfz2r57EIaQXGdGnCWdePkagdvbtnDRhKpQeUhcdAE6P/svp_50001/szg_6916_50001_0b6bgyabqaaa74abotmbpzpvcnwdda3aagca.f622.mp4?vkey=456B335414192F2723862FDE0C6793733018F78F5B83F20EE84F839939C1CE24C167F3258A1FF49085AD9ED2723750EEEB43D8E3F8E2675835BFDCD118967B8BC88E12F513D69EE2659D336E3E339B1A30010C378332E012A0DD90707796B7B0594614BA3F234BD22D88DB968AA7DB3D','http://117.169.70.156/om.tc.qq.com/AVkfOyp92Sas5sxe9rpxlHPstJfdRDN5ekGQD8vwPgYQ/uwMROfz2r5zEIaQXGdGnCmdfhzmTk18sX2Ar-h4hnWJblhxX/a0943qw8ttk.m701.mp4?vkey=62BAA3DB7D271858E84780F922211C5A56B96C4E88F0A8425C2DCDAE009C6A8EE9921CD978553FD6A793784D1A93281DDF0CA6A5B952D58033391A4DBA5BE0E8A24AD47C9078F520867F9194E40898ECA4E82C4F8CF6697D12446A93CDBB29890D7408317184742112CF4453F4AF39E6']
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    let that=this;
    wx.request({
      url: "http://localhost:8080/film/getAll",
      method: "POST",
      header: {
        'content-type': 'application/json'
      },
      data: {
        
      },
      // res.data表示成功的时候返回的数据
      success(res) {
        // console.log(res.data);
        if (res.data.code == 200) {
          that.setData({
           film:res.data.data
          })
          console.log(that.data.film)
        }
      }
    }),
    wx.request({
      url: "http://localhost:8080/news/getAll",
      method: "POST",
      header: {
        'content-type': 'application/json'
      },
      data: {
        
      },
      // res.data表示成功的时候返回的数据
      success(res) {
        // console.log(res.data);
        if (res.data.code == 200) {
          that.setData({
           news:res.data.data
          })
          console.log(that.data.news)
        }
      }
    })
   
    // 实例化腾讯地图API核心类
    qqmapsdk = new QQMapWX({
      key: 'GZ6BZ-OL2CD-NI24I-HIXRJ-WVXIJ-5OF6X' // 必填
    });
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
      var latitude = res.latitude
          var longitude = res.longitude
          var speed = res.speed
          var accuracy = res.accuracy
          qqmapsdk.reverseGeocoder({
            location: {
              latitude: latitude,
              longitude: longitude
            },
            success: function (addressRes) {
        console.log(addressRes)
        that.setData({
          address:addressRes
        })
        console.log(that.data.address.result.address_component.city)
        //这里打印出来很多的东西 就有你想要的地址名称
      }
    })
  }
    })
  },
  
  select1(e){
    console.log(e.currentTarget.id)
    this.setData({
      hotFilm:1,
      comeingsoon:0,
      selectId:e.currentTarget.id
    })
  },

  select2(e){
    console.log(e.currentTarget.id)
    this.setData({
      hotFilm:0,
      comeingsoon:1,
      selectId:e.currentTarget.id
    })
  },

  videos1(e){
    this.setData({
      videos:0
    })
  },

  videos2(e){
    this.setData({
      videos:1
    })
  },

  videos3(e){
    this.setData({
      videos:2
    })
  },

  videos4(e){
    this.setData({
      videos:3
    })
  },

  videos11(e){
    this.setData({
      videoss:0
    })
  },

  videos22(e){
    this.setData({
      videoss:1
    })
  },

  videos33(e){
    this.setData({
      videoss:2
    })
  },

  videos44(e){
    this.setData({
      videoss:3
    })
  },

  want(e){
    if(!app.globalData.deng){
      wx.showToast({
          //标识提示信息
          title: '未登录，请先登录用户',
          //图标显示类型
          icon: 'none',
          duration: 2000,
          //显示透明蒙层，防止触摸穿透
          mask: true
      })
      setTimeout(function(){
        wx.switchTab({
          //相对绝对都可
          url: '/pages/user/user'
      })
      },2000,)
     }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady(e) {
   
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  
})